﻿Public Class ClspdAvanceOt
    Inherits ClsSQL

    Dim orden_id As Integer
    Dim avance_id As Integer
    Dim Fecha As Date
    Dim porcentaje As Double
    Dim detalle As String
    Dim observaciones As String
    Dim supervisor_id As Integer
    Dim estado As Integer
    Dim usuario As String
    Dim fechareg As Date

#Region "Propiedades"
    Property Porden_id() As Integer
        Get
            Return orden_id
        End Get
        Set(ByVal value As Integer)
            orden_id = value
        End Set
    End Property

    Property Pavance_id() As Integer
        Get
            Return avance_id
        End Get
        Set(ByVal value As Integer)
            avance_id = value
        End Set
    End Property

    Property Pfecha() As Date
        Get
            Return Fecha
        End Get
        Set(ByVal value As Date)
            Fecha = value
        End Set
    End Property

    Property Pporcentaje() As Double
        Get
            Return porcentaje
        End Get
        Set(ByVal value As Double)
            porcentaje = value
        End Set
    End Property

    Property Pdetalle() As String
        Get
            Return detalle
        End Get
        Set(ByVal value As String)
            detalle = value
        End Set
    End Property

    Property Pobservaciones() As String
        Get
            Return observaciones
        End Get
        Set(ByVal value As String)
            observaciones = value
        End Set
    End Property

    Property Psupervisor_id() As Integer
        Get
            Return supervisor_id
        End Get
        Set(ByVal value As Integer)
            supervisor_id = value
        End Set
    End Property
    Property Pestado() As String
        Get
            Return estado
        End Get
        Set(ByVal value As String)
            estado = value
        End Set
    End Property

    Property Pusuario() As String
        Get
            Return usuario
        End Get
        Set(ByVal value As String)
            usuario = value
        End Set
    End Property

    Property Pfechareg() As Date
        Get
            Return fechareg
        End Get
        Set(ByVal value As Date)
            fechareg = value
        End Set
    End Property

#End Region

#Region "Procedmientos y Funciones"
    Public Function Insertar()
        Dim sql As String
        sql = "INSERT INTO pdAvanceOT VALUES ('" & Porden_id & "','" & Pavance_id & "','" & Pfecha.Date.ToString("yyyyMMdd") & "','" & Pporcentaje & "','" & Pdetalle & "','" & Pobservaciones & "','" & Psupervisor_id & "', '" & Pestado & "', '" & Pusuario & "','" & Pfecha.Date.ToString("yyyyMMdd") & "')"
        Return (Me.Ejecutar(sql))
    End Function
    Public Function Modificar()
        Dim sql As String
        'sql = "UPDATE MOVIMIENTO SET IDTIPOMOVIMIENTO=5 WHERE IDTIPOMOVIMIENTO='" & Pidtipomovimiento() & "' AND IDMOVIMIENTO='" & Pidmovimiento() & "' "
        Return (Me.Ejecutar(sql))
    End Function
    Public Function Eliminar()
        Dim sql As String
        'sql = "UPDATE MOVIMIENTO SET IDTIPOMOVIMIENTO=6 WHERE IDTIPOMOVIMIENTO='" & Pidtipomovimiento() & "' AND IDMOVIMIENTO='" & Pidmovimiento() & "' "
        Return (Me.Ejecutar(sql))
    End Function

    Sub ClsConectar(ByVal bd As String, Optional ByVal servidor As String = "")
        Select Case bd
            Case "administracion"
                Conectar(0)
            Case "corbol"
                Conectar(1)
            Case "importacion"
                Conectar(2)
            Case "corbol09"
                Conectar(3)
            Case "corbol2010"
                Conectar(4)
            Case "pruebas"
                Conectar(5)
            Case "corbol2011"
                Conectar(6)
        End Select
    End Sub
    Sub ClsDesConectar()
        Desconectar()
    End Sub

    Function ClsTraerDataTable(ByVal opcion As Int16, Optional ByVal filtro As String = "") As DataTable
        Select Case opcion
            Case 0
                Return TraerTabla("VpdAvanceOT", "*", "ESTADO=0 ORDER BY ORDEN_ID DESC")
                'Return TraerTabla("Vpdordenfinalisimo", "*", "1=1 ORDER BY ORDEN_ID DESC")
            Case 1
                Return Buscador("VpdAvanceOT", filtro)
            Case 2
                Return Buscador("VpdAvanceOT", "WHERE Orden_id=" & Porden_id() & " ")
            Case 3
                Return TraerTabla("VpdAvanceOT", " * ", filtro)
            Case 4
                Return TraerTabla("VMaxpdAvanceOT", " * ", filtro)
            Case 5
                Return TraerTabla("pdAvanceOT", "ISNULL(Max(Avance_id), 0)", " Orden_id=" & Porden_id())
        End Select
    End Function
    Function ClsTraerDataSet(Optional ByVal opcion As Integer = 0) As DataSet
        'Select Case opcion
        '    Case 0
        '        Return TraerTablaDs("VALMACEN", "*")
        '        'Case 1
        '        '    Return BuscadorDs("VAUTOPORCLIENTE", "WHERE CLIENTE=" & Pidcliente() & " ")
        'End Select
    End Function
#End Region

End Class
